package com.davai.castorplay;

import java.io.FileWriter;
import java.io.IOException;

import org.exolab.castor.mapping.Mapping;
import org.exolab.castor.mapping.MappingException;
import org.exolab.castor.xml.MarshalException;
import org.exolab.castor.xml.Marshaller;
import org.exolab.castor.xml.ValidationException;

public class CastorWriter {

	public static void main(String args[]) throws IOException,
			MarshalException, ValidationException, MappingException {
		Person person = new Person("TOM");
		String hairColor = "purple";
		person.setHairColor(hairColor);

		FileWriter writer = new FileWriter("People1.0.xml");
		Marshaller marshaller = new Marshaller(writer);
		Mapping mapping = new Mapping();
		mapping.loadMapping("mapping1.0.xml");
		marshaller.setMapping(mapping);

		marshaller.marshal(person);

		writer = new FileWriter("People2.0.xml");
		marshaller = new Marshaller(writer);
		mapping = new Mapping();
		mapping.loadMapping("mapping2.0.xml");
		marshaller.setMapping(mapping);

		marshaller.marshal(person);
	}
}
